package robocop;

import java.util.logging.Logger;

import service.AccountProcessor;

import com.google.wave.api.AbstractRobotServlet;
import com.google.wave.api.RobotMessageBundle;


@SuppressWarnings("serial")
public class RobocopServlet extends AbstractRobotServlet {
	
	private static final Logger log = Logger.getLogger(RobocopServlet.class.getName());
	
	static final String APP_NAME = "account-360";
	
	private static final String BOT_ADDRESS = APP_NAME + "@appspot.com";

	@Override
	public void processEvents(RobotMessageBundle bundle) {
		processBlips(bundle);
	}
	
	/** Process any blips which have changed. */
	private void processBlips(RobotMessageBundle bundle) {
		
	AccountProcessor accproc = AccountProcessor.getInstance();
	accproc.applyProcessorsToChangedBlips(bundle,	BOT_ADDRESS);
	}
	
/*	@Override
	public void processEvents(RobotMessageBundle bundle) {
	    Wavelet wavelet = bundle.getWavelet();
	              
	    if (bundle.wasSelfAdded()) {
	      Blip blip = wavelet.appendBlip();
	      TextView textView = blip.getDocument();
	      textView.append("I Got You!");
	    }
	            
	    for (Event e: bundle.getEvents()) {
	      if (e.getType() == EventType.WAVELET_PARTICIPANTS_CHANGED) {    
	        Blip blip = wavelet.appendBlip();
	        TextView textView = blip.getDocument();
	        textView.insertInlineBlip(0);
	        StyledText stText = new StyledText("Hi, You changed the Participants!!!");
	        stText.addStyle(StyleType.BOLD);
	        stText.addStyle(StyleType.ITALIC);
	        textView.appendStyledText(stText);
	        //textView.append("Hi, You changed the Participants!!!");
	      }
	      if (e.getType() == EventType.WAVELET_SELF_ADDED) {    
		        Blip blip = wavelet.appendBlip();
		        TextView textView = blip.getDocument();
		        textView.append("Hi, I was Self Added!!");
	      }
	      if (e.getType() == EventType.WAVELET_BLIP_CREATED) {    
		        Blip blip = wavelet.appendBlip();
		        TextView textView = blip.getDocument();
		        textView.append("Hi, Blip Created!!");
	      }
	      if (e.getType() == EventType.WAVELET_BLIP_REMOVED) {    
		        Blip blip = wavelet.appendBlip();
		        TextView textView = blip.getDocument();
		        textView.append("Hi, I Blipc Removed!!");
	      }
	      if (e.getType() == EventType.WAVELET_TIMESTAMP_CHANGED) {    
		        Blip blip = wavelet.appendBlip();
		        TextView textView = blip.getDocument();
		        textView.append("Hi, You changed something...!!");
	      }
	      if (e.getType() == EventType.WAVELET_SELF_ADDED) {    
		        Blip blip = wavelet.appendBlip();
		        TextView textView = blip.getDocument();
		        textView.append("Hi, I was Self Added!!");
	      }
if(e.getType() == EventType.WAVELET_TIMESTAMP_CHANGED)
{
	log.info("Change in Time Stamp:: Created on " +bundle.getWavelet().getCreationTime());
	log.info("Last Modified By " +bundle.getWavelet().getLastModifiedTime());
	
	
}
if (e.getType() == EventType.BLIP_SUBMITTED) {    
    Blip blip = wavelet.appendBlip();
    TextView textView = blip.getDocument();
    StyledText stText = new StyledText("Hi, So you changed something!!");
    stText.addStyle(StyleType.BOLD);
    stText.addStyle(StyleType.ITALIC);
    textView.appendStyledText(stText);
//    textView.append("Hi, So you changed something!!");
    log.info("Adding Style Text");
}

	    }
	  }*/

	
}
